<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //创建Map
        let teacher = new Map([
            ["name", "邓睿"],
            ["gender", "男"],
            ["web", "dengruicode.com"]
        ])
        console.log(teacher)

        //set：添加
        teacher.set("height", 177)
        console.log(teacher)

        //delete：删除
        teacher.delete("height")
        console.log(teacher)

        //has：看Map里是否有这组键值对
        console.log(teacher.has("name"))
        console.log(teacher.has("weight"))

        //size：Map的长度
        console.log(teacher.size)
        //Arrry.from（）:将Map转成数组
        let arr = Array.from(teacher)
        console.log("arr", arr)
        //[...xxx]:使用扩展运算符将Map转成数组
        let arr2 = [...teacher]
        console.log("arr2", arr2)
        //for...of解构Map
        for (let [key, value] of teacher) {
            console.log("key", key, "value", value)
        }
        //forEach解构Map(value和key传入的顺序与for..of相反的)
        teacher.forEach((value, key) => {
            console.log("forEachkey", key, "forEachvalue", value)
        })
        //清除Map
    </script>
</body>

</html>